package com.hui.config.security.filter;

import com.alibaba.fastjson.JSONObject;
import com.hui.config.security.utils.CrosUtil;
import com.hui.dto.JsonResult;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RestLogoutHandler implements LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        JsonResult jsonResult = new JsonResult();
        jsonResult.setMsg("登出后的处理");
        CrosUtil.crosOrgin(request, response);
        response.getWriter().write(JSONObject.toJSONString(jsonResult));
    }
}
